package com.zking.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/*
一般对于配置类来说，都是加@Configuration注解
虽然和@Component/@Repository/@Service/@Controller一样
 */
// @Component
@Configuration
public class MyConfig1 {
    // 配置Mybatis-plus自带的分页插件
    // 如何使用：使用Mapper.selectPage()方法即可
    @Bean
    public MybatisPlusInterceptor interceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor p = new PaginationInnerInterceptor();
        p.setDbType(DbType.MYSQL);
        interceptor.addInnerInterceptor(p);
        return interceptor;
    }
}
